﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Emgu.CV;
using Emgu.Util;
using System.Drawing;

namespace ObjectTracking
{
    public class ColorTracking
    {

        public static IntPtr GetTresholdedImage(IntPtr image)
        {
            IntPtr imgHSV = CvInvoke.cvCreateImage(CvInvoke.cvGetSize(image) , Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_64F , 3);
            CvInvoke.cvCvtColor(image , imgHSV , Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2HSV);
            IntPtr imgTresholded = CvInvoke.cvCreateImage(CvInvoke.cvGetSize(image) , Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_64F , 1);
            CvInvoke.cvInRangeS(imgHSV, new Emgu.CV.Structure.MCvScalar(46, 80, 60), new Emgu.CV.Structure.MCvScalar(60, 255, 200), imgTresholded);
            CvInvoke.cvReleaseImage(ref imgHSV);   
            return imgTresholded;
        }
    }
}
